#pragma once

template<class iterator, class Ref, class Ptr>
class Reserve_iterator
{
	typedef Reserve_iterator<iterator, Ref, Ptr> Self;
public:
	Reserve_iterator(const iterator& it)
		:_it(it)
	{}

	Ref& operator*()
	{
		iterator rit = _it;
		return *(--rit);
	}

	Ptr& operator->()
	{
		iterator rit = _it;
		return operator->(--rit);
	}

	Self& operator--()
	{
		_it++;
		return *this;
	}

	Self operator--(int)
	{
		Self tmp(_it);
		_it++;
		return tmp;
	}

	Self& operator++()
	{
		_it--;
		return *this;
	}

	Self operator++(int)
	{
		Self tmp(_it);
		_it--;
		return tmp;
	}

	bool operator==(const Self& s)
	{
		return _it == s._it;
	}

	bool operator!=(const Self& s)
	{
		return _it != s._it;
	}

private:
	iterator _it;
};